import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'chartDataFilter'
})
export class ChartDataFilterPipe implements PipeTransform {

  transform(datatype: string, data?: Array<object>): any {
    switch(datatype){
      case '1001': {
        const _data = {
          'VA': [],
          'VB': [],
          'VC': []
        };
        data['data'].forEach(element => {
          const atTime = parseInt(element.FreezeTime, 10);
          _data.VA.push([atTime, element.VA]);
          _data.VB.push([atTime, element.VB]);
          _data.VC.push([atTime, element.VC]);
        });
        return _data;
      };

      case '1002': {
        const _data = {
          'VA': [],
          'VB': [],
          'VC': []
        };
        data['data'].forEach(element => {
          const atTime = parseInt(element.FreezeTime, 10);
          _data.VA.push([atTime, element.VA]);
          _data.VB.push([atTime, element.VB]);
          _data.VC.push([atTime, element.VC]);
        });
        return _data;
      };

    }

  }

}
